package com.cy.myblog.service.impl;

import com.cy.myblog.dao.MenuDaoI;
import com.cy.myblog.model.Tmenu;
import com.cy.myblog.service.MenuServiceI;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2015/7/13.
 */
@Service("menuService")
public class MenuServiceImpl implements MenuServiceI{

    private MenuDaoI menuDao;

    @Resource(name = "menuDao")
    public void setMenuDao(MenuDaoI menuDao) {
        this.menuDao = menuDao;
    }

    @Override
    public List<Tmenu> findAll() {
        String hql = "from Tmenu";
        List<Tmenu> tmenus = menuDao.find(hql);
        System.out.println(tmenus);
        if (tmenus != null && tmenus.size() > 0) {
            return tmenus;
        }
        return null;
    }

    @Override
    public void save(Tmenu menu) {
       menuDao.save(menu);
    }

    @Override
    public Tmenu getById(String id) {
       return menuDao.getById(Tmenu.class,id);
    }
}
